<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html lang="zh-CN">
<head>
<title>创建券</title>
<body>
	<div style="color: red;font-size: 20px;">创建完后请试着给自己发一张，确保各项设置都没问题</div>
	<c:if test="${type=='cash_coupon' }">
	<h4>新建现金券</h4>
	<table id="cashcoupondiv">
		<tr>
			<td>类型</td>
			<td><input type="radio" value="priciple" name="addProfit" />赠本金 <input checked="checked" type="radio" value="profit" name="addProfit" />赠息</td>
		</tr>
		<tr>
			<td>现金券名称</td>
			<td><input class="name" style="width: 300px;"
				placeholder="建议格式：ＸＸ红包－Ｎ天Ｎ元以上使用" /></td>
		</tr>
		<tr>
			<td>面额</td>
			<td><input class="amt" />不大于100元</td> 
		</tr>
		<tr>
			<td>数量</td>
			<td><input class="quantity" value="200000" /></td>
		</tr>
		<tr>
			<td>有效天数</td>
			<td><input class="validday" value="100" /></td>
		</tr>
		<tr>
			<td>起购金额</td>
			<td><input class="buy_amount" placeholder="最少1000元" /></td>
		</tr>
		<tr>
			<td>起购期限(天数)</td>
			<td><input class="period" /></td>
		</tr>
		<tr>
			<td></td>
			<td><button id="btn-create-cashcoupon">新建现金券</button></td>
		</tr>
	</table>
	</c:if>
	
	
	<c:if test="${type=='rate_incr_coupon' }">
	<h4>新建加息券</h4>
	<table id="rateIncrcoupondiv">
		<tr>
			<td>加息券名称</td>
			<td><input class="name" style="width: 300px;"
				placeholder="建议格式：ＸＸ红包－Ｎ天Ｎ元以上使用" /></td>
		</tr>
		<tr>
			<td>加息额度%</td>
			<td><input class="amt" />0~10</td> 
		</tr>
		<tr>
			<td>数量</td>
			<td><input class="quantity" value="200000" /></td>
		</tr>
		<tr>
			<td>有效天数</td>
			<td><input class="validday" value="100" /></td>
		</tr>
		<tr>
			<td>起购金额</td>
			<td><input class="buy_amount" placeholder="最少1000元" /></td>
		</tr>
		<tr>
			<td>起购期限(天数)</td>
			<td><input class="period" /></td>
		</tr>
		<tr>
			<td></td>
			<td><button id="btn-create-rateincrcoupon">新建加息券</button></td>
		</tr>
	</table>
	</c:if>
	
	<script src="../static/jquery-1.11.0.js"></script>
	<script type="text/javascript">
		$(function() {

			$("#btn-create-cashcoupon").click(function() {
				var p  ={
						t:new Date(),
						name:$("#cashcoupondiv").find(".name").val().trim(),
						amount:$("#cashcoupondiv").find(".amt").val().trim(),
						totalQuantity:$("#cashcoupondiv").find(".quantity").val().trim(),
						validDay:$("#cashcoupondiv").find(".validday").val().trim(),
						buyAmount:$("#cashcoupondiv").find(".buy_amount").val().trim(),
						period:$("#cashcoupondiv").find(".period").val().trim(),
						usedQuantity:0,
						type:$(":checked").val().trim()
				};  
				$.post("create_cash_coupon_def.htm",p,function(data){
					alert(JSON.stringify(data));
				},"json");
			});

			
			$("#btn-create-rateincrcoupon").click(function() {
				var p  ={
						t:new Date(),
						name:$("#rateIncrcoupondiv").find(".name").val().trim(),
						amount:$("#rateIncrcoupondiv").find(".amt").val().trim(),
						totalQuantity:$("#rateIncrcoupondiv").find(".quantity").val().trim(),
						validDay:$("#rateIncrcoupondiv").find(".validday").val().trim(),
						buyAmount:$("#rateIncrcoupondiv").find(".buy_amount").val().trim(),
						period:$("#rateIncrcoupondiv").find(".period").val().trim(),
						usedQuantity:0
				}; 
				$.post("create_rate_incr_coupon_def.htm",p,function(data){
					alert(JSON.stringify(data));
				},"json");
			});

		});
	</script>
</body>
</html>
